//<script>
var simple = Ext.create('Ext.form.Panel', {
    url:BASE_MARCAS+'save',
    bodyStyle:'padding:5px 5px 0',
    width: 350,
    fieldDefaults: {
        msgTarget: 'side',
        labelWidth: 75
    },
    defaultType: 'textfield',
    defaults: {
        anchor: '100%'
    },
    items: [
        {fieldLabel: 'Nombre',name: 'nombre',allowBlank:false},
    ],
    buttons: [
        {
            text: 'Guardar',
            handler: function() {
                var form = this.up('form').getForm();
                form.submit({
                    clientValidation: true,
                    success: function(form, action) {
                        Ext.Msg.alert(
                            'Operación Exitosa',
                            action.result.msg,
                            function(){
                                Ext.getCmp('<?php echo $gridPanelId?>').getStore().load();
                            }
                        );
                        formMarcas.close();
                        formMarcas.destroy();
                    },
                    failure: function(form,action){
                        switch (action.failureType) {
                          case Ext.form.Action.CLIENT_INVALID:
                             Ext.Msg.alert('Failure', 'Form fields may not be submitted with invalid values');
                             break;
                          case Ext.form.Action.CONNECT_FAILURE:
                             Ext.Msg.alert('Failure', 'Ajax communication failed');
                             break;
                          case Ext.form.Action.SERVER_INVALID:
                            Ext.Msg.alert('Failure', action.result.msg);
                            break;
                          default:
                            Ext.Msg.alert('Failure',action.result.msg);
                        }
                    },
                    scope:this
                });
            }
        }
    ]
});
var formMarcas = Ext.create('Ext.Window', {
    title: 'Nueva Marca',
    layout: 'fit',
    modal: true,
    items:simple
}).show();